package com.topboya.officeuser.handler;

import com.topboya.officeuser.annotation.MyField;
import org.apache.ibatis.logging.stdout.StdOutImpl;
import org.omg.CORBA.SetOverrideType;
import org.springframework.util.StringUtils;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SourceAccessInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        System.out.println("进入拦截器了");
//
//        HandlerMethod handlerMethod = (HandlerMethod) handler;
//        System.out.println(handlerMethod.getMethodParameters());
//        System.out.println(handlerMethod.getMethod().getName());
//        MyField myField = handlerMethod.getMethod().getAnnotation(MyField.class);
////        if(myField!=null) {
////            if (!StringUtils.isEmpty(myField.value())) {
////                System.out.println(myField.value());
////                System.out.println("请求被拦截！");
////                return false;
////            }
////        }
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {

    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {

    }
}